/*
   Copyright (C) 2008 Yen-Ju Chen <yjchenx gmail>

   This application is free software; you can redistribute it and/or 
   modify it under the terms of the MIT license. See COPYING.

*/

#import "ICItem.h"
#import "GNUstep.h"

#define ICItemIdentifierKey (@"Identifier")
#define ICItemTypeKey (@"Type")
#define ICItemTitleKey (@"Title")

@implementation ICItem: NSObject

- (id) initWithPropertyList: (NSDictionary *) propertyList
{
	self = [self init];
	[self setIdentifier: [propertyList objectForKey: ICItemIdentifierKey]];
	[self setType: [[propertyList objectForKey: ICItemTypeKey] intValue]];
	[self setTitle: [propertyList objectForKey: ICItemTitleKey]];
	return self;
}

/** Override */
- (id) init
{
	self = [super init];
	type = ICItemGeneType;
	return self;
}

- (void) dealloc
{
	DESTROY(identifier);
	DESTROY(title);
	DESTROY(DNASequence);
	[super dealloc];
}

/** Accessory */
- (void) setIdentifier: (NSString *) i
{
	ASSIGNCOPY(identifier, i);
}

- (NSString *) identifier
{
	return identifier;
}

- (void) setTitle: (NSString *) t
{
	ASSIGN(title, t);
}

- (NSString *) title
{
	return title;
}

- (void) setDNASequence: (BCSequence *) s
{
	ASSIGN(DNASequence, s);
}

- (BCSequence *) DNASequence
{
	return DNASequence;
}

- (void) setType: (ICItemType) t
{
	type = t;
}

- (ICItemType) type
{
	return type;
}

- (NSInteger) length
{
	return [DNASequence length];
}

- (NSDictionary *) propertyList
{
	return [NSDictionary dictionaryWithObjectsAndKeys:
		identifier, ICItemIdentifierKey,
		title, ICItemTitleKey,
		[NSString stringWithFormat: @"%d", type], ICItemTypeKey,
		nil];
}

@end

